package mvp.com.bbc.ui.presenter;

import javax.inject.Inject;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import mvp.com.bbc.appContact.AppContact;
import mvp.com.bbc.bean.ArtBeans;
import mvp.com.bbc.ui.model.ArtListModel;

/**
 * Created by ${cbf} on 2017/10/9.
 */

public class ArtListPresenter implements AppContact.ArtListPresenter {
    private AppContact.ArtListView mArtListView;
    private AppContact.ArtListModel mArtListModel;

    @Inject
    public ArtListPresenter(AppContact.ArtListView artListView) {
        mArtListView = artListView;
        mArtListModel = new ArtListModel();
    }

    @Override
    public void artListPresenter(String themeid, String currentPage, String userid) {
        mArtListModel.artLIstModel(themeid, currentPage, userid)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<ArtBeans>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull ArtBeans artBeans) {
                        mArtListView.artListView(artBeans);
                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
